﻿using System;

namespace HmmmIDE.Debug
{
    public class Register : IComparable<string>
    {
        /// <summary>
        /// Value containing in the register
        /// </summary>
        public short Value { get; set; }
        /// <summary>
        /// Name of the register. e.g. r1
        /// </summary>
        public string Name { get { return string.Format("r{0}", RegisterNumber); } }
        /// <summary>
        /// Register number
        /// </summary>
        public int RegisterNumber { get; private set; }

        public Register(int i)
        {
            this.RegisterNumber = i;
        }

        public int CompareTo(string value)
        {
            if (value[0] != 'r')
                return -1;
            int result = -1;
            if (!int.TryParse(value.Substring(1), out result))
                return 1;
            return RegisterNumber - result;
        }
    }
}
